<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>用户密码修改</title>
</head>

<body>
	<script language="Javascript">
		
	function(){

   ajaxSub = false,

    showError = function(msg){

        if(msg){

            $('#er_txt').html(msg).show();

        }else{
            
            $('#er_txt').html('').hide();

        }

    },

    checkpwd = function(that){
            
            var txt = that.val();

            txt = txt.replace(/(^\s*)|(\s*$)/g,'');

            if(!txt){

                showError('原密码不能为空');

                return;
            }


            if(txt.length < 6 || txt.length > 20){

                showError('密码长度为6-20个字符');

                return;
            }

            showError(0);

    },

    newPwd = function(that){
            
            var pwd = that.val(),

                reg = /(.)\1\1/;

            if(!pwd){

                    showError('密码不能为空');

                    return false;

            }


            if(pwd.length < 6 || pwd.length > 20){

                    showError('请控制您的密码在6-20之内');

                    return false;

            }

            if(pwd.length > 0 && reg.test(pwd) ){

                    showError('密码含有连续相同字符');

                    return false;

            }

            showError(0);

            return true;
            
    },

    rNewPwd = function(that){

            var password = $('#newPwd').val(),

                password2 = that.val();;

            if(!password2){

                    showError('请再次输入您的密码');

                    return false;

            }

            if(password != password2){

                    showError('两次输入的密码请保持一致！');

                    return false;
            }

            showError(0);

            return true;
    },

    subFun = function(){

            var data = {};

            checkpwd($('#oldPwd'));

            if( !newPwd($('#newPwd')) ) return;

            if( !rNewPwd($('#rNewPwd')) ) return;


            if(ajaxSub) return;

            ajaxSub = true;

            data.o = $('#oldPwd').val();

            data.n = $('#newPwd').val();

            data.r = $('#rNewPwd').val();

            $.ajax({

                    type : 'get',

                    //url : ucWap.dataUrl+'wap/resetpwd/',
                    
                    url : 'http://www.example.com/resetpwd/o/'+data.o+'/n/'+data.n+'/r/'+data.r+'',

                    data : data,

                    dataType : 'jsonp',

                    success : function(data){

                        if(data.status == 'success'){

                            $('#mdPwd_b').hide();

                            $('#mdPwd_a').show();

                        }else{

                            showError(data.msg);

                        }

                        ajaxSub = false;

                    },

            });

            return false;

    };

    $(document).delegate('#oldPwd','blur',function(){

        checkpwd($(this));

    }).delegate('#newPwd','blur',function(){

        newPwd($(this));

    }).delegate('#rNewPwd','blur',function(){

        rNewPwd($(this));

    }).delegate('#mdPwd','click',function(){

        subFun();

    });


};
	
	
	
	</script>
	
	
	
	
<table width="600" border="1">
  <tbody>
    <tr>
      <th colspan="4" scope="col">用户密码修改</th>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>旧密码：</td>
      <td><input class="password inputpwd" id="oldpwd" name="oldpwd" type="password" ></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>新密码：</td>
      <td><input class="password inputpwd" id="newpwd" name="newpwd" type="password" ></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>重新输入密码：</td>
      <td><input class="password inputpwd" id="quepwd" name="rnewpwd" type="password" ></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><input type="button" name="button" onClick="rec(ajaxSub)" value="提交" ></td>
      <td><input type="button" name="button" onClick="rec(ajaxSub)" value="重置" ></td>
      <td>&nbsp;</td>
    </tr>
  </tbody>
</table>
	
	
	
	
	
</body>
</html>
